<?php

use think\migration\Migrator;
use think\migration\db\Column;

class LyDistributorsSharingStatisticsAddFields extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('distributors_sharing_statistics')
            ->addColumn('common_recharge_price', 'decimal', ['precision'=>10,'scale'=>'2','default' => '0.00','comment'=>'非虚拟支付充值金额','after' => 'virtual_scale'])
            ->addColumn('common_refund_price', 'decimal', ['precision'=>10,'scale'=>'2','default' => '0.00','comment'=>'非虚拟支付退款金额','after' => 'common_recharge_price'])
            ->addColumn('common_scale', 'decimal', ['precision'=>4,'scale'=>'2','default' => '0.00','comment'=>'非虚拟支付分成比例','after' => 'common_refund_price'])
            ->addColumn('ad_incentive_amount', 'decimal', ['precision'=>10,'scale'=>'2','default' => '0.00','comment'=>'广告激励金','after' => 'common_scale'])
            ->update();
    }

    public function down()
    {
        $this->table('distributors_sharing_statistics')
            ->removeColumn('common_recharge_price')
            ->removeColumn('common_refund_price')
            ->removeColumn('common_scale')
            ->removeColumn('ad_incentive_amount')
            ->save();
    }
}
